<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="btn">click</button>
    <script>
        const btn = document.getElementById('btn');
        function a() {
            console.log("点击了");
        }
        function throttle(fn, delay) {
            let oldTime = Date.now()
            return function (...args) {
                let nowTime = Date.now()
                if (nowTime - oldTime > delay) {
                    fn.call(this, ...args);
                    oldTime = nowTime;
                }
            }
        }
        btn.addEventListener('click', throttle(a, 1000))
    </script>


</body>

</html>